package edu.towson.cis.cosc490.smith.lab4;

import edu.towson.cis.cosc490.smith.lab4.R;
import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.MenuInflater;
import android.view.MenuItem;
import android.view.View;
import android.widget.AdapterView.AdapterContextMenuInfo;
import android.widget.CheckBox;
import android.widget.EditText;
import android.widget.RadioButton;
import android.widget.Toast;

public class AddNewItemActivity extends Activity {

	EditText editTextMessage;
	RadioButton highButton;
	RadioButton mediumButton;
	RadioButton lowButton;
	CheckBox finishedBox;
	 
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.add_item);
        editTextMessage=(EditText)findViewById(R.id.editText2);
        highButton = (RadioButton)findViewById(R.id.radio0);
        mediumButton = (RadioButton)findViewById(R.id.radio1);
        lowButton = (RadioButton)findViewById(R.id.radio2);
        finishedBox = (CheckBox)findViewById(R.id.checkBox1);
    }
   

	public void addItem(View V)
	{
		// get the Entered  message
		String item = editTextMessage.getText().toString();
		Intent intentMessage = new Intent();
		
		// Debugging toast
		Toast.makeText( AddNewItemActivity.this,
						"Add new item: " + item,
						Toast.LENGTH_LONG).show();
		
		// Radio buttons
		if(highButton.isChecked())
			intentMessage.putExtra("PRIORITY", "HIGH");
		else if(mediumButton.isChecked())
			intentMessage.putExtra("PRIORITY", "MEDIUM");
		else if(lowButton.isChecked())
			intentMessage.putExtra("PRIORITY", "LOW");
		
		// Check box
		if(finishedBox.isChecked())
			intentMessage.putExtra("FINISHED", "TRUE");
		else
			intentMessage.putExtra("FINISHED", "FALSE");
		
		
		// put the message in Intent
		intentMessage.putExtra("ITEM", item);

		setResult(2,intentMessage);
	
        finish();
	}
    
}
